<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>新增</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<include file="common/tag"/>
	</head>
	<link rel="stylesheet" href="/static/plugin/ace/css/chosen.css" />
	<script src="/static/plugin/ace/js/chosen.jquery.min.js"></script>
	<script src="/static/plugin/ace/js/jquery.autosize.min.js"></script>
	<script src="/static/plugin/ace/js/jquery.inputlimiter.1.3.1.min.js"></script>
	<style>
		body{
			background-color:#fff
		}
		.yui_right{
			float: right;
			margin-bottom: 20px;
		}
	</style>
	<body >
	<div>
		<div class="widget-main">

			<input type="hidden" name="__token__" value="{$Request.token}" />

			<div>
				<label >保密等级</label>
				<input type="text" name="name" placeholder="保密等级" class="form-control" />
			</div>

			<br>

			<div>
				<label >状态</label>
				<select class="form-control" name="status">
					<option value="0">关闭</option>
					<option value="1">开启</option>
				</select>
			</div>

			<br>

			<div>
				<label >备注</label>
				<textarea class="autosize-transition form-control" name="description"></textarea>
			</div>

			<br>

			<button class="btn btn-primary yui_right" id="yui_save">
				<i class="icon-plus align-top bigger-125"></i>
				保存
			</button>


		</div>
	</div>

	</body>

	<script>
		$(function () {
            $(".chosen-select").chosen();
            $('textarea[class*=autosize]').autosize({append: "\n"});
            $('textarea.limited').inputlimiter({
                remText: '%n character%s remaining...',
                limitText: 'max allowed : %n.'
            });

            //新增管理员
            $("#yui_save").on('click' , function(){

                var name=$("input[name='name']").val();
                var description=$("textarea[name='description']").val();
                var status=$("select[name='status']").val();
                var __token__=$("input[name='__token__']").val();
				//ajax提交数据
                $.post("/index.php/admin/role/role_add",
                    {
                        name:name,
                        description:description,
                        status:status,
                        __token__:__token__
                    },
                    function(data,status){
                        if (data['code']==1){
                            layer.open({
                                title: '提示',
                                content: '操作成功'
                                ,yes: function(index, layero){
                                    window.parent.location.reload();
                                },cancel: function(){
                                    window.parent.location.reload();
                                }
                            });
						}else{
                            layer.msg(data['text']);
						}
                	}, "json"
                );
            });

        });
	</script>

</html>
